﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinformUpperDataCollections.Models;

namespace WinformUpperDataCollections
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            SqlSugarScope db = SqlSugarHelper.Db;
            //int PageIndex = uPager1.PageIndex; // pagenumber是从1开始的不是从零开始的
            //int PageSize = uPager1.PageSize;
            int TotalCount = 0;
            //单表分页
            var page = db.Queryable<ProductionWorkorder>().ToPageList(uPager1.PageIndex, uPager1.PageSize, ref TotalCount);
            uPager1.RecordCount = TotalCount;
            dtGridView.DataSource = page;           
        }

        private void uPager1_PageChanged(object sender, EventArgs e)
        {
            int PageIndex = uPager1.PageIndex; // pagenumber是从1开始的不是从零开始的
            int PageSize = uPager1.PageSize;
            int TotalCount = 0;
            SqlSugarScope db = SqlSugarHelper.Db;
            //单表分页
            var page = db.Queryable<ProductionWorkorder>().ToPageList(PageIndex, PageSize, ref TotalCount);
            dtGridView.DataSource = page;
            uPager1.RecordCount = TotalCount;
        }
    }
}
